package com.ibm.spatiotemp.test.mock;

import java.util.Collection;
import java.util.LinkedList;
import java.util.List;

import org.apache.log4j.Logger;

import com.ibm.spatiotemp.datamodel.datatype.request.TSBuildIdxRequest;
import com.ibm.spatiotemp.datamodel.datatype.timeseries.GPSTimeseries;
import com.ibm.spatiotemp.datamodel.datatype.timeseries.MockingTimeSeries;
import com.ibm.spatiotemp.source.DataSourceDescriber;
import com.ibm.spatiotemp.source.GPSDataSource;

public class MockGPSDataSouce implements GPSDataSource{

	public static Logger logger = Logger.getLogger(MockGPSDataSouce.class);
	
	DataSourceDescriber srcdesc;
	
	public MockGPSDataSouce()
	{
		srcdesc = new DataSourceDescriber();
		srcdesc.setOutput_root_uri("");
		srcdesc.setSrccrential("mockingstring");
		srcdesc.setSrcid("mockingstc");
	}
	
	@Override
	public Collection<GPSTimeseries> getTimeseriesesByTimeRange(long startdate,
			long enddate) {
		Collection<GPSTimeseries> res = new LinkedList<GPSTimeseries>();
		Collection<String> tsidlst = listTimeseriesID();
		for (String tsid : tsidlst) {
			res.add(getTimeseriesByTSIDAndTimeRange(tsid,startdate,enddate));
		}
		return res;
	}
	
	@Override
	public GPSTimeseries getTimeseriesByTSIDAndTimeRange(String tsid,
			long startdate, long enddate) {
		return new MockingTimeSeries(tsid);
	}
	
	@Override
	public GPSTimeseries getTimeseriesByTSIDAndTimeRange(TSBuildIdxRequest req) {
		return getTimeseriesByTSIDAndTimeRange(req.getTsid(),req.getStartts(),req.getEndts());
	}

	@Override
	public DataSourceDescriber getDataSourceDescriber() {
		// TODO Auto-generated method stub
		return srcdesc;
	}

	@Override
	public Collection<String> listTimeseriesID() {
		// TODO Auto-generated method stub
		List<String> result = new LinkedList<>();
		result.add("1");
		return result;
	}

	@Override
	public Long getIndexScale() {
		return (long)(1*24*3600*1000);
	}

	@Override
	public Long getMostEarlyTimeStamp() {
		// TODO Auto-generated method stub
		return System.currentTimeMillis() - getIndexScale();
	}


}
 